﻿using Newtonsoft.Json;
namespace Gx.Common
{
    public class JsonHelper
    {
        /// <summary>
        /// 转换成json
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static string SerializeObject<T>(T obj)
        {
            return JsonConvert.SerializeObject(obj);
        }

        /// <summary>
        /// json转换成对象
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="str"></param>
        /// <returns></returns>
        public static T DeserializeObject<T>(string str)
        {
            return JsonConvert.DeserializeObject<T>(str);
        }
    }
}
